var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, s) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var s in e)
              Object.prototype.hasOwnProperty.call(e, s) && (t[s] = e[s]);
          })(e, s);
      };
      return function (e, s) {
        function a() {
          this.constructor = e;
        }
        if ("function" != typeof s && null !== s)
          throw new TypeError(
            "Class extends value " + String(s) + " is not a constructor or null"
          );
        t(e, s),
          (e.prototype =
            null === s
              ? Object.create(s)
              : ((a.prototype = s.prototype), new a()));
      };
    })(),
  AXLegatusView = (function (t) {
    function e(e) {
      var s = t.call(this) || this;
      return (
        (s.onLoadJiNengShengJiFn = {
          caller: s,
          code: 1408,
          method: function (t) {
            if (0 == t.code) {
              s.listArr = t.data;
              var e;
              s.dataSource = [];
              for (var a = 0; a < s.listArr.length; a++)
                (e = {
                  legatusName: { text: s.listArr[a].name },
                  legatusDescr: {
                    text: s.listArr[a].grade + " 级 " + s.listArr[a].skillName,
                  },
                  legatusButton: { label: s.dealButtonLabelText() },
                }),
                  s.dataSource.push(e);
              (s.list_legatus.visible = !0),
                (s.list_legatus.array = s.dataSource);
            }
          },
        }),
        (s.onLoadFuJiangXueXiListFn = {
          caller: s,
          code: 1409,
          method: function (t) {
            if (0 == t.code) {
              s.listArr = t.data;
              var e;
              s.dataSource = [];
              for (var a = 0; a < s.listArr.length; a++)
                (e = {
                  legatusName: {
                    text: s.listArr[a].name + " " + s.listArr[a].lvl + " 级",
                  },
                  legatusDescr: {
                    text: s.dealsuboardStateFn(s.listArr[a].pos),
                  },
                  legatusButton: {
                    label: s.dealFuJiangStudyState(s.listArr[a].s),
                  },
                }),
                  s.dataSource.push(e);
              (s.list_legatus.visible = !0),
                (s.list_legatus.array = s.dataSource);
            } else ToastView.toastView(t.msg);
          },
        }),
        s.btn_legatues_cancle.on(Laya.Event.CLICK, s, s.onLegatuesClose),
        (s.list_legatus.selectEnable = !0),
        s.list_legatus.on(Laya.Event.CLICK, s, s.onLegatuesDidClickFn),
        (s.list_legatus.vScrollBarSkin = ""),
        (s.list_legatus.renderHandler = new Laya.Handler(
          s,
          s.updateLegatusItem
        )),
        WebSocketService.addListener(s.onLoadJiNengShengJiFn),
        WebSocketService.addListener(s.onLoadFuJiangXueXiListFn),
        WebSocketService.addListener({
          caller: s,
          code: 1397,
          method: s.onLoadFuJiangJiNengShengJi,
        }),
        s
      );
    }
    return (
      __extends(e, t),
      (e.showLegatusView = function (t) {
        return (
          null == this.legatusV && (this.legatusV = new e(t)),
          (this.legatusV.list_legatus.visible = !1),
          (this.legatusV.legatus_type = t),
          "1" == t
            ? ((this.legatusV.lbl_legatusTitle.text = "副将技能升级"),
              (this.legatusV.lbl_tipLegatuesMsg.text =
                "注：每次升级消耗20000银币"),
              WebSocketService.send({ c: 1408, d: { pageNum: 0 } }))
            : "2" == t
            ? ((this.legatusV.lbl_legatusTitle.text = "副将技能学习"),
              (this.legatusV.lbl_tipLegatuesMsg.text =
                "注：副将学习/重修技能，将自动卸下所有魂蛋。"),
              WebSocketService.send({ c: 1409, d: { pageNum: 0 } }))
            : "3" == t &&
              ((this.legatusV.lbl_legatusTitle.text = "副将技能学习"),
              (this.legatusV.lbl_tipLegatuesMsg.text =
                "注：副将学习/重修技能，将自动卸下所有魂蛋。"),
              WebSocketService.send({ c: 1408, d: { pageNum: 0 } })),
          this.legatusV
        );
      }),
      (e.prototype.onLoadFuJiangJiNengShengJi = function (t) {
        0 == t.code ? ToastView.toastView(t.data) : ToastView.toastView(t.msg);
      }),
      (e.prototype.dealFuJiangStudyState = function (t) {
        if ("1" == t) return "学习";
      }),
      (e.prototype.dealButtonLabelText = function () {
        return "3" == this.legatus_type
          ? "重修"
          : "1" == this.legatus_type
          ? "升级"
          : "";
      }),
      (e.prototype.updateLegatusItem = function (t, e) {
        if (!(e > this.dataSource.length)) {
          var s = t.getChildByName("legatusButton");
          (s.visible = !0),
            "2" == this.legatus_type &&
              ("1" == this.listArr[e].s
                ? (s.skin = "comp/preload/btn_com_sure.png")
                : ((s.visible = !1), (s.skin = "")));
        }
      }),
      (e.prototype.onLegatuesDidClickFn = function (t) {
        if ("" != t.target.name)
          if ("学习" == t.target.label) {
            i = this.listArr[this.list_legatus.selectedIndex];
            AXStudySkillDialog.showStudySkillView(i, "xuexi");
          } else if ("升级" == t.target.label) {
            var e = this.listArr[this.list_legatus.selectedIndex].skillId,
              s = this.listArr[this.list_legatus.selectedIndex].cid;
            WebSocketService.send({ c: 1397, d: { cid: s, skillid: e } });
          } else if ("重修" == t.target.label) {
            var a = this.listArr[this.list_legatus.selectedIndex];
            AXStudySkillDialog.showStudySkillView(a, "chongxiu");
          } else if (t.target.name) {
            var i;
            (i = this.listArr[this.list_legatus.selectedIndex]).id =
              this.listArr[this.list_legatus.selectedIndex].cid;
            var l = AXSuboardinateDetailView.showSuboardView(i);
            l.pos(0, 35), Laya.stage.addChild(l);
          }
      }),
      (e.prototype.dealsuboardStateFn = function (t) {
        var e = parseInt(t);
        return e >= 1
          ? "已出战"
          : -1 == e
          ? "不可出战"
          : 0 == e
          ? "未出战"
          : void 0;
      }),
      (e.prototype.onLegatuesClose = function () {
        this.removeSelf();
      }),
      e
    );
  })(ui.SubSquareController.AXLegatusViewUI);
